﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using TTGame;

/*
 * GameLauncher
 * 游戏流程，游戏的入口
 *
 *
 * 依赖：
 *
 * ！不写重复代码！
 * @author TTun
 * @date 7/14/2017 9:57:12 AM
 */
namespace TTGameEngine {

public class GameLauncher : MonoBehaviour {

    public static GameLauncher Self;

    void Awake() {
        Self = this;
        DontDestroyOnLoad(gameObject);

        transform.position = Vector3.zero;
        transform.rotation = Quaternion.identity;
    }

    // Use this for initialization
    void Start() {
        if(DebugSetting.Self.Debug_LocalScene) {
            //yield return StartCoroutine(BattleManager.Share().StartBattle());
//             BattleManager.Share().StartBattle();
//             UGUIBattleForm.OpenForm();
        }

    }

    // Update is called once per frame
    void Update() {
        //DebugTime.Ins.CountUpdate();
    }

    /// <summary>
    /// 只是找一个对象挂载全局的逻辑脚本而已。
    /// 注意:
    /// 1、同一个脚本只会挂载一个。
    /// 2、切关不会释放脚本。
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <returns></returns>
    public T AddLogicScript<T>() where T: MonoBehaviour {
        return gameObject.AddComponentSafe<T>();
    }

    Transform tf = null;
    //用于计算的GameObject，全局一个就够了。用来转换面向与四元数。
    public Transform GetCalcObj() {
        if(tf == null) {
            tf = new GameObject("GameObject For Calc").transform;
            tf.parent = transform;
        }
        return tf;
    }

    #region Battle



    #endregion

}

}
